package org.ax.controller.device;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.ax.data.Result;
import org.ax.pojo.device.DeviceFault;
import org.ax.pojo.device.DeviceMaintain;
import org.ax.service.device.DeviceFaultService;
import org.ax.service.device.DeviceMaintainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 编程人:赵浩鑫
 * 时间:2021-02-28-23:16
 */
@RestController
@RequestMapping("/deviceMaintain")
public class DeviceMaintainController {
    @Autowired
    DeviceMaintainService deviceMaintainService;
    @Autowired
    Result result;
    @GetMapping("/list")
    public Result search(String deviceMaintainEmpId,@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "6") int limit){
        Page<DeviceMaintain> deviceMaintainPage = deviceMaintainService.searchDeviceMaintains(new Page(page, limit), deviceMaintainEmpId);
        result.setData(deviceMaintainPage.getRecords());
        result.setCount(deviceMaintainPage.getTotal());
        return result;
    }
    @PostMapping("/add")
    public Result add(DeviceMaintain deviceMaintain){
        result.setMsg(deviceMaintainService.addDeviceMaintain(deviceMaintain)?"添加成功":"添加失败");
        return result;

    }
    @PostMapping("/update")
    public Result update(DeviceMaintain deviceMaintain){
        result.setMsg(deviceMaintainService.updateDeviceMaintain(deviceMaintain)?"修改成功":"修改失败");
        return result;

    }
    @GetMapping("/patchDel")
    public Result patchDel(String[] ids){
        result.setMsg(deviceMaintainService.deletesDeviceMaintain(ids)?"批量删除成功":"批量删除失败");
        return result;
    }
    @GetMapping("/deviceDeviceMaintainList")
    public Result deviceDeviceMaintainList(){
        result.setData(deviceMaintainService.findDeviceMaintains());
        return result;
    }
}
